package bairui.international.weixin.portal.miniapp.controller.proxy.area;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_ProxyAreaAddress;
import bairui.international.service.Service_ProxyAreaAddress;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 *
 * 得到代理区域地址
 *
 * @generated
 * 
 * @see STest_C_Proxy_Area_GetAddress_Get 测试
 *
 */
@Controller
public class C_Proxy_Area_GetAddress_Get
 extends SC_Proxy_Area_GetAddress_Get 
{
	
	@Autowired private Service_ProxyAreaAddress service_ProxyAreaAddress;
	
	/**
	 * Get请求
	 */
	@Action(Get.class)
	@GetMapping(Get.RequestMappingValue)
	public @FomatOutput @ResponseBody Object get(
		ModelMap map, HttpServletRequest request,
		@RequestParam String skey,
		@RequestParam Long townId
	) throws Exception {
		TB_ProxyAreaAddress address = service_ProxyAreaAddress.findOne(it->it.user.skey.eq(skey).and(it.town.id.eq(townId)));
		if(null == address){
			return new Output();
		}
		return new Output(
				townId, 
				address.getAddress(), 
				address.getFixAddress(), 
				address.getPhone(), 
				address.getUsername()
			);
	}
	
	@NoArgsConstructor
	@AllArgsConstructor
	public static class Output {
		private @Getter Long townId;
		private @Getter String address;
		private @Getter String fixAddress;
		private @Getter String phone;
		private @Getter String username;
	}

}
